package com.zhaotianhao.controller;

import com.github.pagehelper.PageInfo;
import com.zhaotianhao.pojo.Funds;
import com.zhaotianhao.pojo.FundsTarde;
import com.zhaotianhao.pojo.Users;
import com.zhaotianhao.service.FundsTardeService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Z-7
 * @Date 2022/3/5
 */
@Controller
@RequestMapping("myfunds")
public class MyFundsController {
    @DubboReference
    private FundsTardeService fundsTardeService;

    @RequestMapping("list")
    public String to_list(HttpServletRequest request,@RequestParam(defaultValue = "1")int pageNum, @RequestParam(defaultValue = "5")int pageSize, Model model){
        Users login_user = (Users) request.getSession().getAttribute("LOGIN_USER");
        if(login_user == null){
            request.setAttribute("message","请登录");
            return "user/user_login";
        }
        PageInfo<FundsTarde> page = fundsTardeService.queryByPage(new FundsTarde().setUserId(login_user.getId()), pageNum, pageSize);
        model.addAttribute("page",page);
        return "funds/my_list";
    }
}
